package gui;

import java.applet.Applet;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.JLabel;
import javax.swing.JButton;

import main.EpistocracyApplet;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class VictoryPanel extends TransparentPanel
{
	private JLabel lblVictory;
	private EpistocracyApplet applet;

	public VictoryPanel(EpistocracyApplet a)
	{
		setPreferredSize(new Dimension(450, 300));
		setLayout(null);
		setOpaque(false);

		lblVictory = new JLabelWhite("Gewonnen!");
		lblVictory.setFont(new Font("Tahoma", Font.BOLD, 48));
		lblVictory.setBounds(10, 11, 430, 135);
		lblVictory.setHorizontalAlignment(JLabel.CENTER);
		add(lblVictory);

		JButton btnZumStartbildschirm = new JButton("zum Startbildschirm");
		btnZumStartbildschirm.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent arg0)
			{
				click();
			}
		});
		btnZumStartbildschirm.setForeground(Color.WHITE);
		btnZumStartbildschirm.setBackground(Color.DARK_GRAY);
		btnZumStartbildschirm.setBounds(258, 266, 182, 23);
		add(btnZumStartbildschirm);

		applet = a;
	}

	public void setVictoryText(String text)
	{
		lblVictory.setText(text);
	}

	private void click()
	{
		applet.requestRanking();
		applet.showMainPanel(this);
	}
}
